
import type { CardDetail, CardListData, CardListParams, CardParams, RuleListData, RuleListParams } from "@/types/card"
import { request } from "@/utils/reuqest"

export const getCardListAPI = (params:CardListParams)=>{
  return request<CardListData>('/parking/card/list','GET',params)
} 
export const createCardAPI =(data:Partial<CardParams>)=>{
  return request('/parking/card','POST',data)
} 

export const getCardDetailAPI = (id:string)=>{
  return request<CardDetail>(`/parking/card/detail/${id}`,'GET')
}

export const updateCardAPI = (data:Partial<CardDetail>)=>{
  return request(`/parking/card/edit`,'PUT',data)
}

export const delCardAPI = (ids: number[]) => {
  // 批量删除时，id用逗号隔开，通过 join 方法拼接字符串
  return request(`/parking/card/${ids.join(',')}`, 'DELETE')
}
  
export const getRuleListAPI = (params:RuleListParams)=>{
  return request<RuleListData>('/parking/rule/list','GET')
}
